package com.example.merchantdemo.callback.controller;

import com.example.merchantdemo.callback.dto.AcceptCallbackReq;
import com.example.merchantdemo.callback.dto.AcceptCallbackResp;
import com.example.merchantdemo.callback.dto.AcceptSellCoinOrderStatusPushReq;
import com.example.merchantdemo.callback.dto.AcceptSellCoinOrderStatusPushResp;
import com.example.merchantdemo.callback.service.CallbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 接收推送控制器
 */
@RestController
@RequestMapping("/callback")
public class CallbackController {
    @Autowired
    private CallbackService callbackService;

    /**
     * 接受支付平台回调接口
     *
     * @param acceptCallbackReq
     */
    @PostMapping("/v1.0/acceptCallback")
    public AcceptCallbackResp acceptCallback(@RequestBody @Valid AcceptCallbackReq acceptCallbackReq) {
        return callbackService.acceptCallback(acceptCallbackReq);
    }

    /**
     * 接收卖币订单状态推送
     * @param req
     * @return
     */
    @PostMapping("/v1.0/acceptSellCoinOrderStatusPush")
    public AcceptSellCoinOrderStatusPushResp acceptSellCoinOrderStatusPush(@RequestBody @Valid AcceptSellCoinOrderStatusPushReq req) {
        return callbackService.acceptSellCoinOrderStatusPush(req);
    }


}
